package com.icloud.common.web.exception;

import com.icloud.common.core.api.IErrorCode;

/**
 * 断言处理类，用于抛出各种API异常
 * Created by im on 2020/2/27.
 */
public class Asserts {
    public static void fail(String message) {
        throw new ApiException(message);
    }

    public static void fail(String message, Object... arguments) {
        throw new ApiException(message, arguments);
    }

    public static void fail(IErrorCode errorCode) {
        throw new ApiException(errorCode);
    }

    public static void fail(IErrorCode errorCode, Object... arguments) {
        throw new ApiException(errorCode, arguments);
    }

    public static void fail(boolean isThrow,IErrorCode errorCode){
        if(isThrow){
            throw new ApiException(errorCode);
        }
    }

    public static void fail(boolean isThrow,String message){
        if(isThrow){
            throw new ApiException(message);
        }
    }

}
